#include <iostream>  //stdio.h
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int main()
{
	//char数组
	char buf[10]="hello";
	cout<<"字符数组直接打印数组名:   "<<buf<<endl;
	//打印buf的首地址
	cout<<&buf[0]<<endl;
	cout<<buf[0]<<endl;  //经典错误
	
	//打印char数组的地址
	cout<<(int *)buf<<endl;  //告诉g++编译器不要把buf默认当成字符串处理，而是要当成指针处理
	
	
	//char类型的指针
	char *p=(char *)malloc(10);
	strcpy(p,"world");
	cout<<"char类型指针直接打印名字:   "<<p<<endl;
	cout<<"char类型指针打印首地址:   "<<(int *)p<<endl;
	printf("p指向的堆空间首地址:%p\n",p);
	
	//int类型
	int array[5]={45,96.78,85,11};
	cout<<"整型数组直接打印数组名:   "<<array<<endl;
	
	printf("buf的首地址:%p\n",buf);
	printf("buf的首地址:%p\n",&buf[0]);
}